#include "SEL.h"

using namespace SEL;

//const int max_count = 1000;
const int max_count = 1;

const int max_width = 640;
const int max_height = 480;


int main ()
{
	init (INIT_TIMER);
	
	Uta uta (0, 0, 640 * 2, 480 * 2);
	
	srand (500);

	std::cout << "Adding " << max_count << " rectangles" << std::endl;
	Uint32 time = SDL::GetTicks ();
	Sint16 x, y;
	Uint16 w, h;
	for (int i = 0; i < max_count; ++i)
	{	
	    x = rand () % max_width;
	    y = rand () % max_height;
	    w = rand () % max_width;   // in fact the max. width is 2 x max_width...
	    h = rand () % max_height;  // detto
	    uta += Rect (x, y, w, h);
	}

	time = SDL::GetTicks () - time;
	std::cout << "Duration: " << time << " ms" <<  std::endl;
		
	SDL::Rect *rects;
	int num;
	time = SDL::GetTicks ();
	num = uta.getRectangles (rects);
	time = SDL::GetTicks () - time;
	
	std::cout << "Converting to rectangles: " << time << " ms" << std::endl;
	
	for (int i = 0; i < num; ++i)
	{
	    std::cout << (i + 1) << ".  "  << rects [i].x << ", " << rects [i].y 
		      << ", "  << rects [i].w << ", " << rects [i].h << std::endl;
	}
	delete [] rects;

	quit ();
	return 0;
};
